package com.example.bingobox.service;

import android.accessibilityservice.AccessibilityService;
import android.content.Context;
import android.content.Intent;
import android.provider.Settings;
import android.text.TextUtils;

public class AccessibilityManager {
    private static AccessibilityManager instance;
    private MyAccessibilityService service;

    private AccessibilityManager() {}

    public static AccessibilityManager getInstance() {
        if (instance == null) {
            instance = new AccessibilityManager();
        }
        return instance;
    }

    public void setService(MyAccessibilityService service) {
        this.service = service;
    }

    public boolean isAccessibilityEnabled(Context context) {
        String serviceName = context.getPackageName() + "/" + MyAccessibilityService.class.getCanonicalName();
        String enabledServices = Settings.Secure.getString(
                context.getContentResolver(),
                Settings.Secure.ENABLED_ACCESSIBILITY_SERVICES
        );
        return enabledServices != null && enabledServices.contains(serviceName);
    }

    public void performBack() {
        if (service != null) {
            service.performGlobalAction(AccessibilityService.GLOBAL_ACTION_BACK);
        }
    }

    public void performHome() {
        if (service != null) {
            service.performGlobalAction(AccessibilityService.GLOBAL_ACTION_HOME);
        }
    }
} 